package br.ufrj.dcc.comp2.musica.vista;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import br.ufrj.dcc.comp2.musica.controle.ControleCardLayout;

//niiiiiiiiiiiiiiiiice xD


public class PainelCadastrarTurmasCampos extends JPanel {
	
	private JLabel labelCodigo;
	private JLabel labelDisciplina;
	private JLabel labelVagas;
	private JLabel labelCurso;
	private JLabel labelProfessor;
	
	private JTextField campoCodigo;
	private JTextField campoVagas;
	
	private JComboBox comboCurso;
	private JComboBox comboDisciplina;
	private JComboBox comboProfessor;
	
	private JButton botaoCadastrar;
	private JPanel painelBotao = new JPanel();
	
	private GridBagLayout gridBagLayout = new GridBagLayout();
	private GridBagConstraints gridBagConstraints = new GridBagConstraints();
	
	private ControleCardLayout controleCardLayout;

	public PainelCadastrarTurmasCampos(ControleCardLayout controleCardLayout) {
		
		this.controleCardLayout = controleCardLayout;
		labelCodigo = new JLabel("Codigo:");
		labelDisciplina = new JLabel("Disciplina:");
		labelVagas = new JLabel("Vagas:");
		labelCurso = new JLabel("Curso:");
		labelProfessor = new JLabel("Professor:");
		
		campoCodigo = new JTextField(10);
		campoVagas = new JTextField(10);
		
		comboCurso = new JComboBox();
		comboDisciplina = new JComboBox();
		comboProfessor = new JComboBox();
		
		botaoCadastrar = new JButton("Cadastrar");
		setLayout(gridBagLayout);

		setBorder(BorderFactory.createTitledBorder("Cadastrar turma"));
		
		// adicionar labels na coluna '1'
		adicionar(labelCodigo, 1, 0);
		adicionar(labelCurso, 1, 1);
		adicionar(labelDisciplina, 1, 2);
		adicionar(labelProfessor, 1, 3);
		adicionar(labelVagas, 1, 4);

		// adicionar campos, coluna '3'
		adicionar(campoCodigo, 3, 0);
		adicionar(comboCurso, 3, 1);
		adicionar(campoVagas, 3, 4);

		// adicionar comboBox
		adicionar(comboDisciplina, 3, 2);
		adicionar(comboProfessor, 3, 3);

		// adicionar Botao
		painelBotao.add(botaoCadastrar);
		adicionar(painelBotao, 3, 5);
	}

	public void adicionar(Component c, int x, int y) {
		gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
		gridBagConstraints.insets = new Insets(6, 6, 6, 6);
		gridBagConstraints.gridx = x;
		gridBagConstraints.gridy = y;
		gridBagConstraints.ipady = 3;

		add(c, gridBagConstraints);
	}

	public void adicionar(Component c, int x, int y, int fill) {
		gridBagConstraints.fill = fill;
		gridBagConstraints.gridx = x;
		gridBagConstraints.gridy = y;
		gridBagConstraints.ipady = 3;

		add(c, gridBagConstraints);
	}

	public JTextField getCampoCodigo() {
		return campoCodigo;
	}

	public JTextField getCampoVagas() {
		return campoVagas;
	}

	public JComboBox getComboCurso() {
		return comboCurso;
	}

	public JComboBox getComboDisciplina() {
		return comboDisciplina;
	}

	public JButton getBotaoCadastrar() {
		return botaoCadastrar;
	}

	public JComboBox getComboProfessor() {
		return comboProfessor;
	}
	
	public ControleCardLayout getControleCardLayout() {
		return controleCardLayout;
	}

	public void setComboCurso(JComboBox comboCurso) {
		this.comboCurso = comboCurso;
	}

	public void setComboDisciplina(JComboBox comboDisciplina) {
		this.comboDisciplina = comboDisciplina;
	}

	public void setComboProfessor(JComboBox comboProfessor) {
		this.comboProfessor = comboProfessor;
	}
}
